package com.bjdd.jdy.ui.news;

import com.bjdd.jdy.util.JumpUtil;
import com.bjdd.jdy.util.SpUtil;

/**
 * Created by Administrator on 2017/5/3.
 */

public class NewsPresenter extends NewsContract.Presenter {
    @Override
    public void onStart() {
        if (SpUtil.getUser() == null || SpUtil.getUser().equals("") || SpUtil.getUser().getCarrierId() == null) {
            JumpUtil.toLogin(context);
            return;
        }
    }

    @Override
    void getNews() {
        String token = SpUtil.getToken();
        String carrierId = SpUtil.getUser().getCarrierId();
        rxManager.add(model.getNewModel(token,carrierId)
        .subscribe(result -> {
            if (!result.isError()){
                view.newsBack(result.getData());
            }
        },e -> {

        }));
    }
}
